////////////////////////////////////////////////////////////////////////////////
// Filename: L_dx11vertexshader.cpp
////////////////////////////////////////////////////////////////////////////////
#include "L_dx11vertexshader.h"

L_DX11VertexShader::L_DX11VertexShader()
{
	Shader = 0;
	Buffer = 0;
}

L_DX11VertexShader::~L_DX11VertexShader()
{

}

bool L_DX11VertexShader::Init(ID3D11Device* Device, string FileName, string EntryPoint, string ShaderModel)
{
	HRESULT hr;

	hr = D3DX11CompileFromFile(FileName.c_str(), 0, 0, EntryPoint.c_str(), ShaderModel.c_str(), 0, 0, 0, &Buffer, 0, 0);
	if(FAILED(hr))
	{
		MessageBox(NULL, "Error compiling vertex shader", "Error", MB_OK | MB_ICONERROR);
		return false;		
	}

	hr = Device->CreateVertexShader(Buffer->GetBufferPointer(), Buffer->GetBufferSize(), NULL, &Shader);
	if(FAILED(hr))
	{
		MessageBox(NULL, "Error creating vertex shader", "Error", MB_OK | MB_ICONERROR);
		return false;		
	}

	return true;
}

ID3D11VertexShader* L_DX11VertexShader::GetShader()
{
	return Shader;
}

ID3D10Blob* L_DX11VertexShader::GetBuffer()
{
	return Buffer;
}